package Kuaishou;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;

import com.google.common.base.Strings;
import com.google.common.collect.Lists;

/**
 * @author leiwenkang <leiwenkang@kuaishou.com>
 * Created on 2021-04-26
 */
public class Test41Trim {

    public static void main(String[] args) {
        List<String> keyWordList = Lists.newArrayList("test", "Test", "Te st", "te st");
        System.out.println(trimAndToLowerCase(keyWordList));
        System.out.println("te st".replace( " ", ""));
    }

    private static List<String> trimAndToLowerCase(List<String> keyWordList) {
        if (CollectionUtils.isEmpty(keyWordList)) {
            return Collections.emptyList();
        }

        return keyWordList.stream().map(str -> str.replace(" ", "")).map(String::toLowerCase).collect(Collectors.toList());
    }
}
